home *** CD-ROM | disk | FTP | other *** search
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
- * |_o_o|\\ Copyright (c) 1989 The Software Distillery. *
- * |. o.| || All Rights Reserved *
- * | . | || Written by John Toebes and Doug Walker *
- * | o | || The Software Distillery *
- * | . |// 235 Trillingham Lane *
- * ====== Cary, NC 27513 *
- * BBS:(919)-471-6436 *
- \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- #include "pickpack.h"
- #include "struct.h"
- #include "viewgen.h"
-
- static struct IntuiText IText =
- {
- 1,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 0,0, /* XY origin relative to container TopLeft */
- &TOPAZ80, /* font pointer or NULL for default */
- NULL, /* pointer to text */
- NULL /* next IntuiText structure */
- };
-
- void stviewnew(nw, it, stnode)
- struct NewWindow **nw;
- struct IntuiText **it;
- struct STNODE *stnode;
- {
- *nw = &NewWindowStructure1;
- stnode->d.bdata->Gadget1 = Gadget1;
- stnode->d.bdata->Gadget3 = Gadget2;
- stnode->d.bdata->Gadget3 = Gadget3;
- stnode->d.bdata->Gadget1SInfo = Gadget1SInfo;
-
- stnode->d.bdata->Gadget2.NextGadget = &stnode->d.bdata->Gadget1;
- stnode->d.bdata->Gadget3.NextGadget = &stnode->d.bdata->Gadget2;
- stnode->d.bdata->Gadget1.SpecialInfo = (APTR)&stnode->d.bdata->Gadget1SInfo;
- stnode->d.bdata->pos = 0;
- NewWindowStructure1.FirstGadget = &stnode->d.bdata->Gadget1;
- *it = NULL;
- return;
- }
-
- #define HEXASC 44
-
- /* Display the struct FileHandle */
- int stviewdisp(n)
- struct STNODE *n;
- {
- return(stviewmove(n, 0));
- }
-
- /* Display the struct FileHandle */
- int stviewmove(n, adj)
- struct STNODE *n;
- int adj;
- {
- char data[100];
- char *p;
- int i, off, len;
- int dlines, wlines;
- int hpot, hbody;
-
- INITTEXT(14)
-
- BUG(1, ("stviewdisp: Entry, stnode 0x%08x window 0x%08x\n", n, n->w))
- IText.IText = (UBYTE *)data;
-
- wlines = (n->w->Height - 13)/9;
- dlines = n->d.vdata->lines;
- if (wlines >= dlines)
- {
- off = 0;
- hpot = 0;
- hbody = -1;
- }
- else
- {
- if (n->d.bdata->Gadget1SInfo.VertPot == 0xffff)
- off = dlines-wlines+adj;
- else
- off = ((n->d.bdata->Gadget1SInfo.VertPot*(dlines-wlines)+32000) >> 16)+adj;
- if (off >= dlines-wlines)
- {
- hpot = -1;
- off = dlines-wlines;
- }
- else if (off <= 0)
- {
- off = 0;
- hpot = 0;
- }
- else
- hpot = (off<<16)/(dlines-wlines);
- hbody = (wlines<<16)/dlines;
- dlines = wlines;
- }
-
- /* Off is the line number I expect to go to */
- /* n->d.vdata->pos is the current line number */
- /* n->d.vdata->posptr is the pointer to the current line */
- /* wlines is the number of lines on the screen */
- /* dlines is the number of data lines to be displayed */
-
- BUG(3,("hpot=%d hbody=%d dlines=%d wlines=%d\n",hpot,hbody,dlines,wlines))
- ModifyProp(&n->d.bdata->Gadget1, n->w, NULL,
- AUTOKNOB+FREEVERT, -1, hpot, -1, hbody);
-
- /* Now get our pointer to the correct line */
- if (off <= n->d.vdata->pos)
- {
- p = n->d.vdata->buf;
- n->d.vdata->pos = off;
- }
- else
- {
- p = n->d.vdata->posptr;
- if (p == NULL) p = n->d.vdata->buf;
- off -= n->d.vdata->pos;
- n->d.vdata->pos += off;
- }
-
- while(off--)
- p += strlen(p)+1;
-
- /* We are pointing at the first line of the page */
- n->d.vdata->posptr = p;
-
- for(i = 0; i<dlines; i++)
- {
- len = strlen(p);
- memset(data, ' ', 95);
- if (len > 95) len = 95;
- memcpy(data, p, len);
- data[95] = 0;
- p += strlen(p)+1;
- SHOWTEXT
- }
-
- memset(data, ' ', 95);
- data[95] = 0;
- while(i++ < wlines)
- {
- SHOWTEXT
- }
-
- BUG(1, ("stviewdisp: Exit\n"))
- return(RC_OK);
- }
-